package net.esj.basic.core.view.tools.searcher;

import java.util.Collection;
import java.util.Collections;

public interface Searcher {

	static final String REQUEST_SEARCH_KEY = "_REQUEST_SEARCH_KEY";
	
	/**
	 * 获得所有的搜索条件
	 * @return
	 */
	Collection<SearcherColumn> getColumns();
	
	/**
	 * 获得所有排序条件
	 * @return
	 */
	Collection<SearcherColumn> getOrders();
	
	/**
	 * 根据关键字获得搜索条件
	 * @param key
	 * @return
	 */
	Collection<SearcherColumn> getColumnsByKey(String key);
	
	/**
	 * 清除所有搜索条件
	 */
	void clearAll();
	
	/**
	 * 清除某一项搜索条件
	 * @param key
	 */
	void clearByKey(String key);
	
	/**
	 * 清除某个搜索项
	 * @param id
	 */
	void clearById(String id);
	
	/**
	 * 清除所有排序项
	 */
	void clearOrderAll();
	
	/**
	 * 新增搜索条件
	 * @param key
	 * @param view
	 * @param value
	 */
	void newColumn(String key, String view,String type,Object value);
	
	/**
	 * 新增搜索条件
	 * @param column
	 */
	void newColumn(SearcherColumn column);
	
	String getKey();
	
	void newOrderBy(String key,String view,Object value,int index);
	
	void newOrderBy(String key,String view,Object value);
	
	void newOrderBy(SearcherColumn column,int index);
	
	void newOrderBy(SearcherColumn column);
	
	boolean isEmpty();
	
	public static final Searcher EMPTY = new Searcher() {
		
		@Override
		public void newOrderBy(SearcherColumn column) {
			
		}
		
		@Override
		public void newOrderBy(SearcherColumn column, int index) {
			
		}
		
		@Override
		public void newOrderBy(String key, String view, Object value) {
			
		}
		
		@Override
		public void newOrderBy(String key, String view, Object value, int index) {
		}
		
		@Override
		public void newColumn(SearcherColumn column) {
			
		}
		
		@Override
		public void newColumn(String key, String view, String type, Object value) {
			
		}
		
		@Override
		public Collection<SearcherColumn> getOrders() {
			return Collections.EMPTY_LIST;
		}
		
		@Override
		public String getKey() {
			return null;
		}
		
		@Override
		public Collection<SearcherColumn> getColumnsByKey(String key) {
			return Collections.EMPTY_LIST;
		}
		
		@Override
		public Collection<SearcherColumn> getColumns() {
			return Collections.EMPTY_LIST;
		}
		
		@Override
		public void clearOrderAll() {
		}
		
		@Override
		public void clearByKey(String key) {
		}
		
		@Override
		public void clearById(String id) {
		}
		
		@Override
		public void clearAll() {
		}

		@Override
		public boolean isEmpty() {
			return true;
		}
	};
	
}
